package com.cdy.client.handler;

import com.cdy.common.response.RequestUploadResponse;
import com.cdy.common.response.Response;
import io.netty.channel.ChannelHandlerContext;

import java.util.concurrent.CompletableFuture;

import static com.cdy.client.netty.NettyClient.responseFuture;

/**
 * 请求处理器
 *
 * Created by 陈东一
 * 2019/10/20 0020 12:36
 */
public class RequestUploadResponseHandler implements ResponseHandler {
    
    @Override
    public void handle(ChannelHandlerContext ctx, Response msg) {
        System.out.println(ctx.channel());
        CompletableFuture<Response> future = responseFuture.remove(((RequestUploadResponse) msg).getRequestId());
        if (future !=null) {
            future.complete(msg);
        }
    }
}
